/*Class Building
 * 
 * 
 * 
 * 
 */

package disasterGameProj;

import java.util.Random;

public class Building 
{
	public int initialDamage;
	public int currentEndurance;
	public int initialPop;
	public int curPop;
	public int fireRate;
	public int diseaseRate;
	public int floodRate;
	public int crumbleRate;
	public int disasterRate;
	public int evacuatedPop;
	public boolean reEnforced;
	public boolean sandBag;
	public boolean barricade;
	public boolean tent;
	public boolean fireTruckPresent;
	public boolean busPresent;
	public boolean helicopterPresent;
	public boolean ambulancePresent;
	public String myName;
	
	public Random generator;
	
	// constructor
	Building( String name )
	{
		myName = name;
		generator = new Random();
		initialDamage = generator.nextInt( 100 - 80 ) + 80;
		currentEndurance = initialDamage;
		initialPop = generator.nextInt( 1000 - 700 ) + 700;
		curPop = initialPop;
		fireRate = 0;
		diseaseRate = 0;
		floodRate = 0;
		crumbleRate = 0;
		disasterRate = 0;
		evacuatedPop = 0;
		reEnforced = false;
		sandBag = false;
		barricade = false;
		tent = false;
		fireTruckPresent = false;
		busPresent = false;
		helicopterPresent = false;
		ambulancePresent = false;
		
	}
	
	public void runProbabilityOfNaturalDeath()
	{
		if( ambulancePresent && curPop > 0 )
			curPop -= ( generator.nextInt( 3 - 1 ) + 1 );
		else
			curPop -= ( generator.nextInt( 10 - 1 ) + 1 );
		
		if( curPop < 0 )
			curPop = 0;
	}
	
	public void runProbabilityOfFire()
	{
		if( fireRate > 0 && currentEndurance > 0 )
		{
			if ( curPop > 0 )
				curPop -= 2 * fireRate;
			
			if( reEnforced && !fireTruckPresent )
				currentEndurance -= 3 * fireRate;
			else if ( fireTruckPresent && !reEnforced )
			{
				currentEndurance -= 2 * fireRate;
				fireRate -= 1;
			}
			else if( fireTruckPresent && reEnforced )
			{
				currentEndurance -= fireRate;
				fireRate -= 1;
			}
			else
				currentEndurance -= 4 * fireRate;
		}
		
		if( currentEndurance < 0 )
			currentEndurance = 0;
		else if ( curPop < 0 )
			curPop = 0;
	}
	
	public void runProbabilityOfDisease()
	{
		if( currentEndurance > 0 )
			currentEndurance -= diseaseRate;
		
		if( diseaseRate > 0 && curPop > 0 )
		{
			
			if( tent && !ambulancePresent )
				curPop -= ( diseaseRate - 1 );
			else if( ambulancePresent && !tent )
				curPop -= ( diseaseRate - 3 );
			else if( tent && ambulancePresent )
				curPop -= ( diseaseRate - 4 );
			
		}
		
		if( currentEndurance < 0 )
			currentEndurance = 0;
		else if ( curPop < 0 )
			curPop = 0;
	}
	
	public void runProbabilityOfFlood()
	{
		
	}
	
	public void runProbabilityOfCrumble()
	{
		
	}
	
	public void runSimulatedDamage()
	{
		runProbabilityOfNaturalDeath();
		runProbabilityOfFire();
		runProbabilityOfDisease();
		runProbabilityOfFlood();
		runProbabilityOfCrumble();
	}
}
